/**
 * React Starter Kit (https://www.reactstarterkit.com/)
 *
 * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.txt file in the root directory of this source tree.
 */

import React, { PropTypes } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './TopicRow.css';
import Link from '../Link';
import history from '../../core/history';
import { Col, Media } from 'react-bootstrap';

class TopicRow extends React.Component {

  static propTypes = {
    index: PropTypes.number.isRequired,
    item: PropTypes.object.isRequired,
  };

  _onClick() {
    history.push(`/topic/${this.props.item._id}`);
  }

  render() {
    return (
      <Col onClick={this._onClick.bind(this)} className={s.item}>
        <Media>
          <Media.Left>
            <Col smHidden xsHidden>
              <img className={s.icon} width={64} height={64} src="http://oeet7xima.bkt.clouddn.com/default_book_icon1.png" alt="Image" />
            </Col>
          </Media.Left>
          <Media.Body className={s.info}>
            <Media.Heading>{this.props.item.title}</Media.Heading>
          </Media.Body>
        </Media>
      </Col>
    );
  }
}

export default withStyles(s)(TopicRow);
